package com.platform.controller.backend;


import com.github.pagehelper.PageInfo;
import com.platform.base.BaseController;
import com.platform.common.Const;
import com.platform.common.ServerResponse;
import com.platform.pojo.Psac0001;
import com.platform.util.NumberUtil;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 供应商基础信息控制层
 */
@RestController
@RequestMapping("/pascController/")
@CrossOrigin(origins = Const.REQUESTURL,maxAge = 3600,allowCredentials = "true")
public class PsacController extends BaseController {

    /**
     * 用户名查询投标人详情，管理员用
     * @param userName
     * @param request
     * @return
     */
    @GetMapping(value = "selectByUserName.do")
    public ServerResponse<Psac0001> selectByUserName(@RequestParam(value = "userName") String userName,HttpServletRequest request){
        return iPsacService.selectByUserName(userName);
    }

    /**
     * 投标人列表页查询
     * @param paramMap
     * @param request
     * @return
     */
    @GetMapping(value = "selectByParamMap.do")
    public ServerResponse<PageInfo> selectByParamMap(@RequestParam Map paramMap,HttpServletRequest request){
        return iPsacService.selectByParamMap(paramMap);
    }

    /**
     * 根据投标人ID查询详情
     * @param id
     * @return
     */
    @GetMapping(value = "selectById.do")
    public ServerResponse<Map> selectById(Integer id){
        return iPsacService.selectById(id);
    }

    /**
     * 根据投标人ID查询详情
     * @param id
     * @return
     */
    @GetMapping(value = "selectOneById.do")
    public ServerResponse<Psac0001> selectOneById(Integer id){
        return iPsacService.selectOneById(id);
    }


    /**
     * 新增
     * @param psac0001
     * @return
     */
    @PostMapping(value = "insert.do")
    public ServerResponse<String> insert(Psac0001 psac0001){
        return iPsacService.insert(psac0001);
    }

    /**
     * 更新
     * @param psac0001
     * @return
     */
    @PostMapping(value = "update.do")
    public ServerResponse<String> update(Psac0001 psac0001){
        return iPsacService.update(psac0001);
    }


    /**
     * 查询投标人详细信息
     * @param paramMap
     * @return
     */
    @GetMapping("selectInfoByUserName.do")
    public ServerResponse<Map> selectInfoByUserName(@RequestParam Map paramMap,HttpServletRequest request){
        return iPsacService.selectInfoByUserName(paramMap,request);
    }

    /**
     * 更新投标人状态
     * @param map
     * @param request
     * @return
     */
    @PostMapping("examine.do")
    public ServerResponse<String> examine(@RequestParam Map map, HttpServletRequest request){
        return iPsacService.examine(map,request);
    }

    /**
     * 查询用户名银行账户信息
     * @param paramMap
     * @return
     */
    @GetMapping("selectBankAccountByUserName.do")
    public ServerResponse<PageInfo> selectBankAccountByUserName(@RequestParam Map paramMap,HttpServletRequest request){
        return iPsacService.selectBankAccountByUserName(paramMap,request);
    }

    /**
     * 查询用户名开票信息
     * @param userName
     * @return
     */
    @GetMapping("selectOpeningInformationByUserName.do")
    public ServerResponse<Map> selectOpeningInformationByUserName(String userName,HttpServletRequest request){
        return iPsacService.selectOpeningInformationByUserName(userName,request);
    }

    /**
     * 更新投标人信息
     * @param paramMap
     * @param request
     * @return
     */
    @PostMapping("updateMap.do")
    public ServerResponse<String> updateMap(@RequestParam Map paramMap,HttpServletRequest request){
        return iPsacService.updateMap(paramMap,request);
    }

    /**
     * 新增银行账户信息
     * @param paramMap
     * @return
     */
    @PostMapping("saveBankData.do")
    public ServerResponse<String> saveBankData(@RequestParam Map paramMap,HttpServletRequest request){

        return iPsacService.saveBankData(paramMap,request);
    }

    /**
     * 更新银行账户信息
     * @param paramMap
     * @param request
     * @return
     */
    @PostMapping("updateBankData.do")
    public ServerResponse<String> updateBankData(@RequestParam Map paramMap,HttpServletRequest request){
        return iPsacService.updateBankData(paramMap,request);
    }


    /**
     * 删除银行账户信息
     * @param paramMap
     * @param request
     * @return
     */
    @PostMapping("delBankById.do")
    public ServerResponse<String> delBankById(@RequestParam Map paramMap,HttpServletRequest request){
        return iPsacService.delBankById(NumberUtil.safeToNumber(paramMap.get("id")),request);
    }

    /**
     * 保存开票信息
     * @param paramMap
     * @param request
     * @return
     */
    @PostMapping("saveTicket.do")
    public ServerResponse<String> saveTicket(@RequestParam Map paramMap,HttpServletRequest request){
        return iPsacService.saveTicket(paramMap,request);
    }


}
